<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="xml"
            encoding="UTF-8"
            indent="yes"
            doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
            doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
            />



    <xsl:template match="/">
        <xsl:call-template name="main"/>
    </xsl:template>




    <xsl:template name="main">
        <xsl:variable name="pageTitle" select="collection/@areaName"/>
        <html>
            <head>
                <title>
                    <xsl:value-of select="$pageTitle"/>
                </title>
                <meta http-equiv="content-type" content="text/html; charset=utf-8" />
                <meta http-equiv="content-language" content="en" />
                <link rel="stylesheet" type="text/css" href="/style.css" media="screen" />
                <link rel="stylesheet" type="text/css" href="" media="print" />
                <meta name="author" content="" />
                <style type="text/css">
                    h1 {
                        margin-left: 0px; margin-right: 0px; margin-top: 0px; margin-bottom: 10px;
                        display: block;
                        float: left;
                        text-align: left;
                        font-weight:normal;
                        color: #7a2b0a;
                        font-size:28px;
                        width:100%;
                    }

                    h2 {
                        margin-left: 0px; margin-right: 0px; margin-top: 2px; margin-bottom: 5px;
                        display: block;
                        float: left;
                        text-align: left;
                        font-weight:normal;
                        color: #333;
                        font-size:18px;
                        width:100%;
                    }

                    h3{
                        margin-left: 0px; margin-right: 0px; margin-top: 0px; margin-bottom: 8px;
                        display: block;
                        float: left;
                        text-align: left;
                        font-weight:normal;
                        color: #444;
                        font-size:12px;
                        width:100%;
                    }
                    #all #middlepanel .navigator li {
                        margin-right: 5px;
                    }

                    .image img {
                        width: 210px; height: 165px;
                    }
                </style>

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-107343-8']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
            </head>
            <body>
                <div id="all"/>
                <div id="middlepanel-images">
                    <div id="middlepanel">
                <!-- Header -->
                        <div class="header">
                            <div class="main-logo">
                                <h1>
                                    <a href="/">
                                        <img src="/images/logo-mapy.png" title="Mollova mapová sbírka" alt="Mollova mapová sbírka" />
                                    </a>
                                </h1>
                            </div>
                            <div class="menu-horizontal">
                                <ul>
                                    <li>
                                        <a href="/virtualni-vystavy/">Výstavy</a>
                                    </li>
                                    <li>
                                        <a href="/ostatni-sbirky-v-mzk/">Další fondy</a>
                                    </li>
                                    <li>
                                        <a href="/o-sbirce/">Historie</a>
                                    </li>
                                    <li>
                                        <a href="/mollova-sbirka/">Mollova sbírka</a>
                                    </li>
                                    <li>
                                        <a href="/hledat/">Hledat</a>
                                    </li>
                                    <li>
                                        <a href="/">Domů</a>
                                    </li>
                                </ul>
                            </div>
                            <div class="navigator">
                                <xsl:call-template name="navigator"/>
                            </div>
                        </div>
                <!-- Header end -->
                <!-- Main historie -->
<!-- Panel Mollova Sbira Signatury -->
                        <div class="window-top-signatury"><xsl:comment></xsl:comment></div>
                        <div class="window-signatury">


                            <div class="signatury-left">
                                <div class="sbirka-menu-top"><xsl:comment></xsl:comment></div>
                                <div class="sbirka-menu">
                                    <div class="sbirka-menu-content">
                                        <div class="sbirka-menu-title">
                                        Atlas Austriacus
                                        </div>
                                        <ul>
                                            <li>
                                                <a href="/mollova-sbirka/rakouske-zeme/">Rakouský kraj</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/ceske-zeme/">České země</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/burgundsky-kraj/">Burgundský kraj</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/italie/">Itálie</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/uhry/">Uhry</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/varia/">Varia</a>
                                            </li>

                                        </ul>
                                    </div>
                                </div>
                                <div class="sbirka-menu-bottom"><xsl:comment></xsl:comment></div>

                                <div class="sbirka-menu-top"><xsl:comment></xsl:comment></div>
                                <div class="sbirka-menu">
                                    <div class="sbirka-menu-content">
                                        <div class="sbirka-menu-title">
                                        Atlas Germanicus
                                        </div>
                                        <ul>
                                            <li>
                                                <a href="/mollova-sbirka/celkove-mapy-uzemi/">Celkové mapy</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/bavorsky-kraj/">Bavorský kraj</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/francky-kraj/">Francký kraj</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/hornorynsky-kraj/">Hornorýnský kraj</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/dolnorynsky-kraj/">Dolnorýnský kraj</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/hornosasky-kraj/">Hornosaský kraj</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/dolnosasky-kraj/">Dolnosaský kraj</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/svabsky-kraj/" id="svab">Švábský kraj</a>
                                            </li>                                            
                                            <li>
                                                <a href="/mollova-sbirka/vestfalsky-kraj/" id="vest">Vestfálský kraj</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/svycarsko/" id="svyc">Švýcarsko</a>
                                            </li>
                                            <li>
                                                <a href="/mollova-sbirka/vodstvo/" id="svyc">Vodstvo Německa</a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                                <div class="sbirka-menu-bottom"><xsl:comment></xsl:comment></div>
                            </div>

                            <div class="signatury-right">
                                <h1>
                                    <xsl:value-of select="$pageTitle"/>
                                </h1>
                                <div class="content">
                                    <p></p>
                                </div>



                                <xsl:call-template name="collection"/>




                            </div>
                        </div>
                        <div class="window-bottom-signatury"><xsl:comment></xsl:comment></div>
<!-- Panel Mollova Sbira Signatury - end-->
                    <!-- Panel  Footer -->
                <div class="window-footer">
                    <div id="menu-footer">
                        <div class="copyright">
			  <a href="http://creativecommons.org/licenses/by-nc-nd/3.0/"><img alt="Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-nd/3.0/80x15.png" /></a>
			</div>
                        <div class="links">
                            <ul>
                                <li><a href="mailto:Jiri.Dufka@mzk.cz">Webmaster</a></li>
                                <li><a href="http://www.facebook.com/pages/Moravsk%C3%A1-zemsk%C3%A1-knihovna/144194955037?v=wall"><img src="/images/ico-logo-fb.png" title="" alt="" /></a></li>
                                <li><a href="http://sites.google.com/site/mollovamapovasbirka/main-page-test/posts.xml"><img src="/images/ico-logo-rss.png" title="" alt="" /></a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <!-- Panel Footer end-->
                    </div>
                </div>
            </body>
        </html>
    </xsl:template>



    <xsl:template name="record">
        <xsl:choose>
            <xsl:when test="@supplemented = 'yes'">
                <xsl:call-template name="supplementedRecord"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="singleRecord"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <xsl:template name="singleRecord">
        <li>
            <div class="image">
                <a>
                    <xsl:attribute name="href">
                        <xsl:value-of select="thumbnail/map"/>
                    </xsl:attribute>
                    <img>
                        <xsl:attribute name="src">
                            <xsl:value-of select="thumbnail/url"/>
                        </xsl:attribute>
                        <xsl:attribute name="title">Mollova mapová sbírka</xsl:attribute>
                        <xsl:attribute name="alt">Mollova mapová sbírka</xsl:attribute>
                    </img>
                </a>
            </div>
            <div class="content">
                <h2>
                    <xsl:call-template name="title"><xsl:with-param name="length">80</xsl:with-param></xsl:call-template>
                </h2>
                <p>
                    <xsl:call-template name="partNumber"/>
                    <xsl:call-template name="author"/>
                    <br/>
                    <xsl:call-template name="publication"/>
                    <h3>Původní signatura: <xsl:value-of select="@signature"/></h3>
                </p>
            </div>
        </li>
    </xsl:template>


    <xsl:template name="supplementedRecord">
        <xsl:variable name="signature">
            <xsl:value-of select="@signature"/>
        </xsl:variable>
        <xsl:for-each select="thumbnail">
            <li>
                <div class="image">
                    <a>
                        <xsl:attribute name="href">
                            <xsl:value-of select="map"/>
                        </xsl:attribute>
                        <img>
                            <xsl:attribute name="src">
                                <xsl:value-of select="url"/>
                            </xsl:attribute>
                            <xsl:attribute name="title">Mollova mapová sbírka</xsl:attribute>
                            <xsl:attribute name="alt">Mollova mapová sbírka</xsl:attribute>
                        </img>
                    </a>
                </div>
                <div class="content">
                    <div style="color:red;">Přívazek k signatuře:</div>
                    <h2><xsl:value-of select="$signature"/></h2>
                </div>
            </li>
        </xsl:for-each>
    </xsl:template>








    <xsl:template name="collection">
        <div class="signatury-items">
            <ul>
                <xsl:for-each select="collection/record">
                    <xsl:call-template name="record"/>
                </xsl:for-each>

            </ul>
        </div>
    </xsl:template>



<!--

    <xsl:template name="title">
        <xsl:param name="length"/>
                <xsl:variable name="nameTitle">
                    <xsl:choose>
                        <xsl:when test="not(substring(title/name,1,1)='[')">
                            <xsl:value-of select="title/name"/>
                        </xsl:when>
                        <xsl:when test="title/partName">
                            <xsl:value-of select="title/partName"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="title/name"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>
                <xsl:choose>
                    <xsl:when test="string-length(normalize-space($nameTitle)) &gt; $length">
                        <xsl:value-of select="substring(normalize-space($nameTitle),1,$length - 3)"/>...
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="normalize-space($nameTitle)"/>
                    </xsl:otherwise>
                </xsl:choose>
    </xsl:template>
-->




    <xsl:template name="title">
        <xsl:param name="length"/>
        <xsl:param name="punctuation"><xsl:text>.:,;/]</xsl:text></xsl:param>
                <xsl:variable name="nameTitle">
                    <xsl:choose>
                        <xsl:when test="not(substring(title/name,1,1)='[')">
                            <xsl:value-of select="title/name"/>
                        </xsl:when>
                        <xsl:when test="title/partName">
                            <xsl:value-of select="title/partName"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="title/name"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>

                <xsl:variable name="nameTitleChopFirst">
                    <xsl:choose>
                        <xsl:when test="substring(normalize-space($nameTitle),1,1)='['">
                            <xsl:value-of select="substring(normalize-space($nameTitle),2,string-length(normalize-space($nameTitle)) - 1)"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$nameTitle"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>

                <xsl:variable name="nameTitleChopLast">
                    <xsl:choose>
                        <xsl:when test="contains($punctuation, substring(normalize-space($nameTitleChopFirst), string-length(normalize-space($nameTitleChopFirst)), 1))">
                            <xsl:value-of select="substring(normalize-space($nameTitleChopFirst),1,string-length(normalize-space($nameTitleChopFirst)) - 1)"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$nameTitleChopFirst"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>

                <xsl:choose>
                    <xsl:when test="string-length(normalize-space($nameTitleChopLast)) &gt; $length">
                        <xsl:value-of select="substring(normalize-space($nameTitleChopLast),1,$length - 3)"/>...
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="normalize-space($nameTitleChopLast)"/>
                    </xsl:otherwise>
                </xsl:choose>
    </xsl:template>

















    <xsl:template name="partNumber">
        <xsl:if test="title/partNumber">
            <h3>Část: <xsl:value-of select="title/partNumber"/></h3>
        </xsl:if>
    </xsl:template>


    <xsl:template name="author">
        <xsl:if test="author">
            <h3 style="font-style: italic;"><xsl:value-of select="author/name"/><xsl:value-of select="author/date"/></h3>
        </xsl:if>
    </xsl:template>

    <xsl:template name="publication">
        <xsl:if test="publication">
            <h3>Nakladatelské údaje: <xsl:value-of select="publication/place"/><xsl:value-of select="publication/name"/><xsl:value-of select="publication/date"/></h3>
        </xsl:if>
    </xsl:template>




    <xsl:template name="supplement">
            <xsl:if test="count(thumbnail/url) > 1">
                <div style="color:red;">Obsahuje přívazky: <xsl:value-of select="count(thumbnail/url)"/></div>
            </xsl:if>
    </xsl:template>



    <xsl:template name="navigator">
        <ul>
            <li>
                <a href="/mollova-sbirka/">Mollova sbírka</a>
            </li>
            <li>></li>
            <li>
                <xsl:variable name="landPath" select="collection/@landPath"/>
                <a href="/mollova-sbirka/{$landPath}/">
                    <xsl:value-of select="collection/@landName"/>
                </a>
            </li>
            <li>></li>
            <li>
                <xsl:value-of select="collection/@areaName"/>
            </li>
        </ul>

    </xsl:template>

</xsl:stylesheet>
